<template>
  <div class="p-5">
    <div style="display: flex;justify-content: space-between;padding-top:20px">
      <button @click="guanbi()" style="color:#fff;background:#2a5eb3;width: 70px;height: 35px;">新增</button>
      <a-select ref="select" v-model:value="select1" style=";margin-bottom: 10px;margin-right: 20px;"
        :placeholder="'请选择Modem'" allowClearget_mset>
        <a-select-option :value="item.value" @click="changeck(item.mtype,item.ip)" v-for="item in dataList"
          :key="item.id">{{
          item.ip
          }}</a-select-option>
      </a-select>
    </div>
  
    <!-- <a-tabs type="card" tabPosition="top" v-model:activeKey="activeKey" @change="changeModem"> -->
    <!-- <a-tab-pane class="tb1" key="info" :tab="'解调器配置'"> -->
    <div v-show="flag">
      <!-- 设备详情页 -->
      <div class="example" v-if="spinflag">
        <a-spin />
      </div>
      <template v-if="dataList.length > 0">
        <template v-if="activeType == 'MT710A'">
          <a-form :model="queryParams" :labelCol="{ span: 5 }" :wrapperCol="{ span: 18 }">
            <!--通道设置-->
            <a-row>
              <a-col :span="24">
                <div class="titlea1">采样配置</div>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="8">
                <a-form-item :label="'存储路径'"><!--通道-->
                  <a-input v-model:value="outPath" @pressEnter="out_save" @blur="out_save" :placeholder="'请输入文件路径'" />
                </a-form-item>
              </a-col>
  
              <!-- <a-col :span="13"> -->
              <!-- <a-form-item :label="'射频通道2'">
                      <a-radio v-model:checked="checked" style="color:#fff;margin-left: 20px;">参与轮询</a-radio>
                      <span style="color: #fff;margin-left: 20px;">卫星名</span>
                      <a-input style="width: 360px;margin-left: 10px;"/>
                    </a-form-item> -->
              <!-- </a-col> -->
              <a-col :span="9">
                <a-form-item :label="'轮询策略'"><!--通道-->
                  <a-select ref="select" v-model:value="select1"
                    style=";margin-bottom: 10px;margin-right: 20px;width: 160px;" :placeholder="'请选择Modem'"
                    allowClearget_mset>
                    <a-select-option :value="item.value" @click="changeck(item.mtype,item.ip)" v-for="item in dataList"
                      :key="item.id">{{
                      item.ip
                      }}</a-select-option>
                  </a-select>
                  <span style="color: #fff">切换时间</span>
                  <a-input style="width: 130px;margin-left: 10px;" />
                </a-form-item>
              </a-col>
              <a-col :span="7">
                <a-form-item :label="'射频通道2'"><!--通道-->
                  <a-checkbox v-model:checked="checkbox1" style="color:#fff">参与轮询</a-checkbox>
                  <span style="color: #fff;margin-left: 10px;">卫星名</span>
                  <a-input style="width: 137px;margin-left: 10px;" />
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="'射频通道3'"><!--通道-->
                  <a-checkbox v-model:checked="checkbox2" style="color:#fff">参与轮询</a-checkbox>
                  <span style="color: #fff">卫星名</span>
                  <a-input style="width: 210px;margin-left: 10px;" />
                </a-form-item>
              </a-col>
              <a-col :span="9">
                <a-form-item :label="'射频通道4'"><!--通道-->
                  <a-checkbox v-model:checked="checkbox3" style="color:#fff">参与轮询</a-checkbox>
                  <span style="color: #fff;margin-left: 10px;">卫星名</span>
                  <a-input style="width: 217px;margin-left: 10px;" />
                </a-form-item>
              </a-col>
              <a-col :span="6">
                <a-button type="primary" style="margin-left: 130px;">采样通道开启</a-button>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="20" :offset="2"><a-divider :span="20" dashed style="border-color: #fff" /></a-col>
            </a-row>
            <!--通道设置-->
            <a-row>
              <a-col :span="24">
                <div class="titlea1">通道配置</div>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.select_chn_title')"><!--通道-->
                  <a-select ref="select" v-model:value="type1chn" style="width: 100%"
                    :placeholder="t('routes.demo.inet.select_chn_placeholder')" :options="chnOptions" @change="changChn">
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="'通道模式'"><!--通道模式-->
                  <a-select ref="select" v-model:value="chnsetParams.chn_type" style="width: 100%"
                    :placeholder="'请选择通道模式'" allowClear>
                    <a-select-option @click="Pattern_click(item)" :value="item.id" v-for="item in Pattern"
                      :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="5" :offset="2">
                <a-form-item :label="t('routes.demo.inet.gather_switch')"><!--采集开关-->
                  <a-switch v-model:checked="checked2" :checkedValue="3" :unCheckedValue="0" @change="changeSwitch"
                    :loading="swithcLoading" />
                </a-form-item>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="20" :offset="2"><a-divider :span="20" dashed style="border-color: #fff" /></a-col>
            </a-row>
            <!--解调配置设置-->
            <a-row v-if="flags">
              <a-col :span="24">
                <div class="titlea1">解调配置</div>
              </a-col>
            </a-row>
            <a-row v-if="flags">
              <!--<a-col :span="8" :offset="0">
                                                                                                  <a-form-item :label="t('routes.demo.inet.channel_switch')">
                                                                                                    <a-switch v-model:checked="checked2" :checkedValue="1" :unCheckedValue="0" @change="changeSwitch2" />
                                                                                                  </a-form-item>
                                                                                                </a-col>-->
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.center_frequency_title')"><!--频率-->
                  <a-input v-model:value="chnsetParams.f"
                    :placeholder="t('routes.demo.inet.center_frequency_placeholder')" />(950,000,000 - 2,150,000,000 Hz)
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.symbol_rate_title')"><!--符号速率-->
                  <a-input v-model:value="chnsetParams.rt"
                    :placeholder="t('routes.demo.inet.symbol_rate_placeholder')" />(sps)
                </a-form-item>
              </a-col>
  
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.RF_IN_title')"><!--射频输入-->
                  <a-select ref="select" v-model:value="chnsetParams.rfin" style="width: 100%"
                    :placeholder="t('routes.demo.inet.RF_IN_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in rfinOptions" :key="item.id">{{
                      item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.spectral_inversion_title')"><!--频谱反转-->
                  <a-select ref="select" v-model:value="chnsetParams.si" style="width: 100%"
                    :placeholder="t('routes.demo.inet.spectral_inversion_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in spectralInversionOptions" :key="item.id">{{
                      item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.rolloff_factor_title')"><!--滚降系数-->
                  <a-select ref="select" v-model:value="chnsetParams.rdc" style="width: 100%"
                    :placeholder="t('routes.demo.inet.rolloff_factor_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in rolloffFactorOptions" :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <div style="width:100%;text-align: center;">
                <a-button type="primary" @click="do_chnset">{{
                  t('routes.demo.inet.save')
                  }}</a-button>
              </div>
            </a-row>
            <a-row><a-col v-if="flags" :span="20" :offset="2"><a-divider :span="20" dashed
                  style="border-color: #fff" /></a-col></a-row>
  
            <!--输出设置-->
            <a-row>
              <a-col :span="24">
                <div class="titlea1">输出配置</div>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.host_ip_title')"><!--输出主机IP-->
                  <a-input v-model:value="outsetParams.sip" :placeholder="t('routes.demo.inet.host_ip_placeholder')" />
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.output_source_port_title')"><!--输出源端口-->
                  <a-input v-model:value="outsetParams.sport"
                    :placeholder="t('routes.demo.inet.output_source_port_placeholder')" />
                </a-form-item>
              </a-col>
  
              <a-col :span="8"><!--*-->
                <a-form-item :label="t('routes.demo.inet.output_format_title')"><!--输出格式-->
                  <a-select ref="select" v-model:value="outsetParams.out_type" style="width: 100%"
                    :placeholder="t('routes.demo.inet.output_format_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in output_formatOptions" :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.chn_BB_frame_timescale_title')"><!--BB帧时标-->
                  <a-select ref="select" v-model:value="outsetParams.bbf" style="width: 100%"
                    :placeholder="t('routes.demo.inet.chn_BB_frame_timescale_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in chn_BBFOptions" :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.output_destination_ip_title')"><!--输出目的IP-->
                  <a-input v-model:value="outsetParams.out_dest_ip"
                    :placeholder="t('routes.demo.inet.output_destination_ip_placeholder')" />
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.output_destination_port_title')"><!--输出目的端口-->
                  <a-input v-model:value="outsetParams.dport"
                    :placeholder="t('routes.demo.inet.output_destination_port_placeholder')" />
                </a-form-item>
              </a-col>
  
              <div style="width:100%;text-align: center;">
                <a-button type="primary" @click="do_outset">{{
                  t('routes.demo.inet.save')
                  }}</a-button>
              </div>
            </a-row>
            <a-row>
              <a-col :span="20" :offset="2"><a-divider :span="20" dashed style="border-color: #fff" /></a-col></a-row>
  
            <!--数据采集设置-->
            <a-row>
              <a-col :span="24">
                <div class="titlea1">数据采集配置</div>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="8" v-if="flags">
                <a-form-item :label="t('routes.demo.inet.data_processing_title')"><!--数据处理方式-->
                  <a-select ref="select" v-model:value="savesetParams.data_processing" style="width: 100%"
                    :placeholder="t('routes.demo.inet.data_processing_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in dataProcessingOptions" :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.file_size_title')"><!--输出文件大小-->
                  <a-input v-model:value="savesetParams.file_size"
                    :placeholder="t('routes.demo.inet.file_size_placeholder')" />单位M
                </a-form-item>
              </a-col>
              <a-col :span="8" v-if="flags">
                <a-form-item :label="t('routes.demo.inet.file_count_title')"><!--输出文件个数-->
                  <a-input v-model:value="savesetParams.file_count"
                    :placeholder="t('routes.demo.inet.file_count_placeholder')" />
                </a-form-item>
              </a-col>
              <a-col :span="8" v-if="flags">
                <a-form-item :label="t('routes.demo.inet.output_path_title')"><!--输出文件路径-->
                  <a-input v-model:value="savesetParams.output_path"
                    :placeholder="t('routes.demo.inet.output_path_placeholder')" />
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.del_bin_title')"><!--删除流文件方式-->
                  <a-select ref="select" v-model:value="savesetParams.delbin" style="width: 100%"
                    :placeholder="t('routes.demo.inet.del_bin_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in delbinOptions" :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8" v-if="flags">
                <a-form-item :label="t('routes.demo.inet.stream_ip_title')"><!--流转发IP-->
                  <a-input v-model:value="savesetParams.stream_ip"
                    :placeholder="t('routes.demo.inet.stream_ip_placeholder')" />
                </a-form-item>
              </a-col>
              <a-col :span="8" v-if="flags">
                <a-form-item :label="t('routes.demo.inet.stream_port_title')"><!--流转发端口-->
                  <a-input v-model:value="savesetParams.stream_port"
                    :placeholder="t('routes.demo.inet.stream_port_placeholder')" />
                </a-form-item>
              </a-col>
              <a-col :span="8" v-if="flags">
                <a-form-item :label="t('routes.demo.inet.sat_name_title')"><!--卫星名称-->
                  <a-input v-model:value="savesetParams.sat_name"
                    :placeholder="t('routes.demo.inet.sat_name_placeholder')" />
                </a-form-item>
              </a-col>
              <a-col :span="8" v-if="flags">
                <a-form-item :label="t('routes.demo.inet.polar_title')"><!--极化方式-->
                  <a-select ref="select" v-model:value="savesetParams.polar" style="width: 100%"
                    :placeholder="t('routes.demo.inet.polar_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in polarOptions" :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8" v-if="flags">
                <a-form-item :label="t('routes.demo.inet.direct_title')"><!--方向指示-->
                  <a-select ref="select" v-model:value="savesetParams.direct" style="width: 100%"
                    :placeholder="t('routes.demo.inet.direct_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in directOptions" :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8" v-if="flags">
                <a-form-item :label="t('routes.demo.inet.hdlc_type_title')"><!--HDLC类型指示-->
                  <a-select ref="select" v-model:value="savesetParams.hdlc_type" style="width: 100%"
                    :placeholder="t('routes.demo.inet.hdlc_type_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in hdlcTypeOptions" :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="'采样时间'"><!--采样时间-->
                  <a-input v-model:value="savesetParams.file_time" :placeholder="'请输入采样时间'" />单位秒
                </a-form-item>
              </a-col>
              <div style="width:100%;text-align: center;margin-bottom: 30px;">
                <a-button type="primary" @click="do_saveset">{{
                  t('routes.demo.inet.save')
                  }}</a-button>
              </div>
            </a-row>
          </a-form>
        </template>
        <template v-else>
          <a-form :model="queryParams" :labelCol="{ span: 5 }" :wrapperCol="{ span: 18 }">
            <a-row>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.select_chn_title')">
                  <a-select ref="select" v-model:value="saveParams2.chn" style="width: 100%"
                    :placeholder="t('routes.demo.inet.select_chn_placeholder')" :options="chn2Options" @change="changChn">
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.gather_switch')">
                  <a-switch v-model:checked="checked1" :checkedValue="checked1 != 0" :unCheckedValue="0"
                    @change="changeSwitch" />
                </a-form-item>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="22" :offset="1"><a-divider :span="20" dashed /></a-col>
            </a-row>
            <a-row>
              <!--<a-col :span="8">
                                                                                                <a-form-item :label="t('routes.demo.inet.ModCode_title')">
                                                                                                  <a-input v-model:value="saveParams.modcode" :placeholder="t('routes.demo.inet.ModCode_placeholder')"/>
                                                                                                </a-form-item>
                                                                                              </a-col>-->
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.listen_ip_title')"><!--监听IP-->
                  <a-input v-model:value="saveParams2.listen_ip"
                    :placeholder="t('routes.demo.inet.listen_ip_placeholder')" />
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.listen_port_title')"><!--监听端口-->
                  <a-input v-model:value="saveParams2.listen_port"
                    :placeholder="t('routes.demo.inet.listen_port_placeholder')" />
                </a-form-item>
              </a-col>
  
              <a-col :span="8"><!--*-->
                <a-form-item :label="t('routes.demo.inet.data_type_title')"><!--数据类型-->
                  <a-select ref="select" v-model:value="saveParams2.data_type" style="width: 100%"
                    :placeholder="t('routes.demo.inet.data_type_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in dataTypeOptions" :key="item.id">{{
                      item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.data_processing_title')"><!--数据处理方式-->
                  <a-select ref="select" v-model:value="saveParams2.data_processing" style="width: 100%"
                    :placeholder="t('routes.demo.inet.data_processing_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in dataProcessingOptions" :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.file_size_title')"><!--输出文件大小-->
                  <a-input v-model:value="saveParams2.file_size"
                    :placeholder="t('routes.demo.inet.file_size_placeholder')" />单位M
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.file_count_title')"><!--输出文件个数-->
                  <a-input v-model:value="saveParams2.file_count"
                    :placeholder="t('routes.demo.inet.file_count_placeholder')" />
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.output_path_title')"><!--输出文件路径-->
                  <a-input v-model:value="saveParams2.output_path"
                    :placeholder="t('routes.demo.inet.output_path_placeholder')" />
                </a-form-item>
              </a-col>
              <a-col :span="8" v-if="saveParams2.data_processing == 1">
                <a-form-item :label="t('routes.demo.inet.del_bin_title')"><!--删除流文件方式-->
                  <a-select ref="select" v-model:value="saveParams2.delbin" style="width: 100%"
                    :placeholder="t('routes.demo.inet.del_bin_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in delbinOptions" :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.stream_ip_title')"><!--流转发IP-->
                  <a-input v-model:value="saveParams2.stream_ip"
                    :placeholder="t('routes.demo.inet.stream_ip_placeholder')" />
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.stream_port_title')"><!--流转发端口-->
                  <a-input v-model:value="saveParams2.stream_port"
                    :placeholder="t('routes.demo.inet.stream_port_placeholder')" />
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.fc_title')"><!--信号载波频率-->
                  <a-input v-model:value="saveParams2.fc" :placeholder="t('routes.demo.inet.fc_placeholder')" />单位: HZ
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.rs_title')"><!--信号信息速率-->
                  <a-input v-model:value="saveParams2.rs" :placeholder="t('routes.demo.inet.rs_placeholder')" />单位kb
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.sat_name_title')"><!--卫星名称-->
                  <a-input v-model:value="saveParams2.sat_name"
                    :placeholder="t('routes.demo.inet.sat_name_placeholder')" />
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.polar_title')"><!--极化方式-->
                  <a-select ref="select" v-model:value="saveParams2.polar" style="width: 100%"
                    :placeholder="t('routes.demo.inet.polar_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in polarOptions" :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.direct_title')"><!--方向指示-->
                  <a-select ref="select" v-model:value="saveParams2.direct" style="width: 100%"
                    :placeholder="t('routes.demo.inet.direct_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in directOptions" :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item :label="t('routes.demo.inet.hdlc_type_title')"><!--HDLC类型指示-->
                  <a-select ref="select" v-model:value="saveParams2.hdlc_type" style="width: 100%"
                    :placeholder="t('routes.demo.inet.hdlc_type_placeholder')" allowClear>
                    <a-select-option :value="item.id" v-for="item in hdlcTypeOptions" :key="item.id">{{ item.name
                      }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="22" :offset="1"><a-divider :span="20" dashed /></a-col>
              <a-col :span="12" :offset="12" style="margin-bottom: 30px;">
                <a-form-item>
                  <a-button type="primary" @click="do_Save2">{{
                    t('routes.demo.inet.save')
                    }}</a-button>
                </a-form-item>
              </a-col>
            </a-row>
          </a-form>
        </template>
      </template>
      <div class="notice1" v-else> 当前解调器无法访问 </div>
    </div>
  
    <!-- </a-tab-pane> -->
  
    <!-- 新增设备 -->
    <!-- <a-tab-pane class="tb1" key="add">
                                                                                <template #tab>
                                                                                  <span class="add1" @click="guanbi()">{{ t('routes.demo.inet.add') }}</span>
                                                                                  <span class="icon5">
                                                                                    <Icon icon="subway:add-1" color="#0960bd" :size="18" />
                                                                                  </span>
                                                                                </template> -->
    <div class="box2" v-show="!flag">
      <a-form :model="queryParams" :labelCol="{ span: 5 }" :wrapperCol="{ span: 18 }">
        <a-row>
          <a-col :span="8">
            <a-form-item :label="t('routes.demo.inet.modems_name_title')">
              <a-input v-model:value="addParams.name" :placeholder="t('routes.demo.inet.modems_name_placeholder')" />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="8">
            <a-form-item :label="t('routes.demo.inet.enter_ip_title')">
              <a-input v-model:value="addParams.ip" :placeholder="t('routes.demo.inet.enter_ip_placeholder')" />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="8">
            <a-form-item :label="t('routes.demo.inet.modems_port_title')">
              <a-input v-model:value="addParams.port" placeholder="3290" />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="8">
            <a-form-item :label="t('routes.demo.inet.select_mtype_title')">
              <a-select ref="select" v-model:value="addParams.mtype" style="width: 100%"
                :placeholder="t('routes.demo.inet.select_mtype_placeholder')" allowClearget_mset>
                <a-select-option :value="item.id" v-for="item in typeOptions" :key="item.id">{{
                  item.name
                  }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="8" :offset="1">
            <a-form-item label="">
              <a-button type="primary" @click="save_add">{{
                t('routes.demo.inet.add1')
                }}</a-button>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- </a-tab-pane> -->
    <!-- </a-tabs> -->
  </div>
</template>

<script lang="ts">
import { useAppStore } from '/@/store/modules/app.ts';
import { defineComponent, reactive, toRaw, ref, onMounted, createVNode } from 'vue';
import type { Router, RouteRecordRaw } from 'vue-router';
import { Form } from 'ant-design-vue';
import {
  get_modem,
  get_chnset1,
  get_outset,
  get_saveset,
  get_chnset2,
  set_chnset1,
  set_saveset,
  set_outset,
  set_chnset2,
  add_modem,
  get_term,
  del_modem,
  set_status,
  set_chn_switch,
  set_chn_type,
  get_getconfig,
  set_setconfig
} from '/@/api/biz/index';
import { Icon } from '/@/components/Icon';
import img3 from '/@/assets/images/224.png';
import { message } from 'ant-design-vue';
import { useI18n } from '/@/hooks/web/useI18n';
import { Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { async } from '../../../../components/Form/src/hooks/useAutoFocus';
import { forEach } from '../../../../utils/helper/treeHelper';

export default defineComponent({
  components: {
    Icon,
  },
  setup() {
    onMounted(() => {
      do_init();
      getList();
      get_outPath()
    });
    const checkbox1 = ref(true)
    const checkbox2 = ref(true)
    const checkbox3 = ref(true)
    const appStore = useAppStore();
    const { t } = useI18n();
    let select1 = ref();
    let flags = ref()
    select1.value = appStore.obj.type || null
    const columns = [
      {
        title: '解调器',
        dataIndex: 'name',
      },
      {
        title: '通道编号',
        align: 'center',
        dataIndex: 'industry',
      },
      {
        title: '中心频率',
        align: 'center',
        dataIndex: 'region',
      },
      {
        title: '符号速率',
        align: 'center',
        dataIndex: 'phone',
      },
      {
        title: '通道锁定',
        align: 'center',
        dataIndex: 'notice_time',
      },
      {
        title: '译码锁定',
        align: 'center',
        dataIndex: 'notice_num',
      },
      {
        title: '解调锁定',
        align: 'center',
        dataIndex: 'status',
      },
      {
        title: '信号功率',
        align: 'center',
        dataIndex: 'declare_time',
      },
      {
        title: '信噪比',
        align: 'center',
        dataIndex: 'files',
        slots: { customRender: 'file' },
      },
      {
        title: '误码率',
        align: 'center',
        slots: { customRender: 'content' },
      },
      {
        title: '频率偏移',
        align: 'center',
        slots: { customRender: 'letterDoc' },
      },
      {
        title: '采集/结束',
        align: 'center',
        dataIndex: 'is_pass',
      },
      {
        title: '审采集状态',
        align: 'center',
        dataIndex: 'inspector_name',
      },

      {
        title: '操作',
        align: 'center',
        fixed: 'right',
        key: 'action',
        width: 220,
        slots: { customRender: 'action' },
      },
    ];
    const typeOptions = ref([]);
    const chnOptions = ref([
      { value: 1, label: '通道1' },
      { value: 2, label: '通道2' },
      { value: 3, label: '通道3' },
      { value: 4, label: '通道4' },
    ]);
    const chn2Options = reactive([
      { value: 1, label: '通道1' },
      { value: 2, label: '通道2' },
      { value: 3, label: '通道3' },
      { value: 4, label: '通道4' },
      { value: 5, label: '通道5' },
      { value: 6, label: '通道6' },
      { value: 7, label: '通道7' },
      { value: 8, label: '通道8' },
    ]);
    const formatOptions = ref([]);
    const rfinOptions = ref([]);
    const bbOptions = ref([]);
    const workingModeOptions = ref([]);
    const spectralInversionOptions = ref([]);
    const rolloffFactorOptions = ref([]);
    let Pattern = ref([{ id: 1, name: '采样' }, { id: 0, name: '采集' }])
    let outPath = ref('')
    function get_outPath() {
      get_getconfig({ name: 'outpath' }).then((res) => {
        if (res.data.data.result.data.value) {
          outPath.value = res.data.data.result.data.value
        } else {
          outPath.value = 'out'
        }
      })
    }
    function out_save(e) {
      set_setconfig({ name: 'outpath', value: e.target.value }).then((res) => {
        if (res.data.data.result.data.code == 200) {
          message.success('保存成功')
        } else {
          message.error(res.data.data.result.data.message)
        }
      })
    }
    let patterns = ref('')
    function Pattern_click(item) {
      patterns.value = item.name
      set_chn_type({ ip: activeKey.value, chn: type1chn.value, chn_type: item.name == '采集' ? 0 : 1 }).then((res) => {
        if (res.data.data.result.data.code == 500) {
          message.error(res.data.data.result.data.message);
        } else {
          getchn(activeKey.value, activeType.value)
          // get_sav(select1.value, activeType.value)
          message.success('操作成功')
          // if (item.name == '采样') {
          //   flags.value = false
          // } else {
          //   flags.value = true
          // }
        }
      })
    }
    const polarOptions = ref([]);
    const directOptions = ref([]);
    const hdlcTypeOptions = ref([]);
    const dataTypeOptions = ref([]);
    const dataProcessingOptions = ref([]);
    const chn_BBFOptions = ref([]);
    const output_formatOptions = ref([]);
    const delbinOptions = ref([])

    const tabPosition = ref(1);
    const addParams = reactive({
      ip: '',
      name: '',
      mtype: '',
      port: 3290,
    });
    const chnsetParams = reactive({
      ip: '',
      chn: '',//
      ena: 1,//通道开关
      rfin: undefined,//频谱反转
      f: undefined,//频率
      rdc: undefined,//滚降系数
      si: undefined,//频谱反转
      rt: undefined,//符号速率
      chn_type: ''
    });
    const outsetParams = reactive({
      ip: '',
      chn: 1,//
      sip: undefined,//输出主机IP
      sport: null,//输出源端口
      out_type: undefined,//输出格式
      bbf: undefined,//BB帧时标
      out_dest_ip: undefined,//输出目的IP
      dport: null,//输出目的端口
    });

    const savesetParams = reactive({
      ip: '',
      chn: 1,
      data_processing: undefined,  // 数据处理方式
      file_size: undefined,  // 文件大小
      file_count: undefined,  // 文件数量
      output_path: '',  // 输出文件路径
      stream_ip: '',  // 流转发IP
      stream_port: undefined,  // 流转发端口
      sat_name: undefined,  // 卫星名称，比如75.5度，实际输入为75.5*100=7550
      polar: undefined,  // 极化方式，0x00：H极化，0x01：V极化
      direct: undefined,  // 方向指示: 0:上行,1:下行
      hdlc_type: undefined,  // HDLC类型指示: 0:标准HDLC,1:非标HDLC
      delbin: undefined,//删除流文件方式
    });

    const saveParams2 = reactive({
      ip: '',
      chn: 1,
      ena: undefined,
      listen_ip: '',  // 监听IP
      listen_port: undefined,  // 监听端口
      data_type: undefined,  // 数据类型 e1|hdlc
      data_processing: undefined,  // 数据处理方式 file/stream
      file_size: undefined,  // 输出文件大小 单位M
      file_count: undefined,  // 输出文件个数
      output_path: '',  // 输出文件路径
      stream_ip: '',  // 流转发IP
      stream_port: undefined,  // 流转发端口
      fc: undefined,  // 信号载波频率（单位：Hz）
      rs: undefined,  // 信号信息速率（单位kb）
      sat_name: undefined,  // 卫星名称，比如75.5度，实际输入为75.5*100=7550
      polar: undefined,  // 极化方式，0x00：H极化，0x01：V极化
      direct: undefined,  // 方向指示: 0:上行,1:下行
      hdlc_type: undefined,  // HDLC类型指示: 0:标准HDLC,1:非标HDLC
      delbin: undefined,//删除流文件方式
    });
    const type1chn = ref(1)
    const saveParams3 = reactive({
      ip: '',
      chn: 1,
      status: 0,

    });
    const saveParams4 = reactive({
      ip: '',
      chn: 1,
      ena: 0,

    });
    const activeKey = ref();
    const activeType = ref();

    const panes = ref();
    const queryParams = reactive({
      cpn: 1,
      epc: 10,
    });
    const chns = ref();
    const chnarr1 = ref();
    const chnarr2 = ref();
    const outarr = ref();
    const savearr = ref();
    const checked1 = ref(1);
    const checked2 = ref(1);
    const dataList = ref([
      {
        name: "142.32.42.28",
        industry: "",
        region: "",
        mtype: 'MT710A',
        phone: "",
        notice_time: "",
        notice_num: "",
        status: "",
        ip: "每日固定时间切换",
        id: '1'
      },
      // {
      //   name: '192.32.10.13',
      //   industry: "",
      //   region: "",
      //   phone: "",
      //   notice_time: "",
      //   mtype: 'MT650A',
      //   notice_num: "",
      //   status: "",
      //   ip: "192.32.10.13",
      //   id: 2
      // },
      // {
      //   name: '192.32.10.38',
      //   industry: "",
      //   region: "",
      //   phone: "",
      //   notice_time: "",
      //   mtype: '',
      //   notice_num: "",
      //   status: "",
      //   ip: "192.32.10.38",
      //   id: 3
      // },
    ]);
    let flag = ref(false)
    function changeck(activeTypes, ipp) {
      activeType.value = activeTypes
      activeKey.value = ipp
      getchn(ipp, activeTypes)
      get_chnset2(ipp)
      if (activeTypes) {
        flag.value = true
      }
    }
    function guanbi() {
      flag.value = false
    }
    const loading = ref(false);

    const paginationOption = reactive({
      showSizeChanger: true,
      total: 0,
      current: 1,
      onChange: changePageInfo,
      onShowSizeChange: changePageInfo,
    });
    function changePageInfo(page, pageSize) {
      queryParams.cpn = page;
      queryParams.epc = pageSize;
      getList();
    }
    function do_init() {
      loading.value = true;
      get_term({})
        .then((res) => {
          console.log(res.data.data.result.data.SELECT.mtype);
          addParams.mtype = res.data.data.result.data.SELECT.mtype.select[0].id;
          typeOptions.value = res.data.data.result.data.SELECT.mtype.select;
          formatOptions.value = res.data.data.result.data.SELECT.out_type.select;
          rfinOptions.value = res.data.data.result.data.SELECT.rfin.select;
          bbOptions.value = res.data.data.result.data.SELECT.bbf.select;
          workingModeOptions.value = res.data.data.result.data.SELECT.work_mode.select;
          spectralInversionOptions.value = res.data.data.result.data.SELECT.si.select;
          rolloffFactorOptions.value = res.data.data.result.data.SELECT.rdc.select;
          polarOptions.value = res.data.data.result.data.SELECT.polar.select;
          directOptions.value = res.data.data.result.data.SELECT.direct.select;
          hdlcTypeOptions.value = res.data.data.result.data.SELECT.hdlc_type.select;
          dataTypeOptions.value = res.data.data.result.data.SELECT.data_type.select;
          dataProcessingOptions.value = res.data.data.result.data.SELECT.data_processing.select;
          chn_BBFOptions.value = res.data.data.result.data.SELECT.bbf.select;
          output_formatOptions.value = res.data.data.result.data.SELECT.out_type.select;
          delbinOptions.value = res.data.data.result.data.SELECT.delbin.select;
          loading.value = false;
        })
        .catch(() => {
          //message.error("连接超时，请稍后再试！");
          loading.value = false;
        });
    }
    function getList() {
      loading.value = true;
      get_modem({})
        .then((res) => {
          appStore.setPanes(res.data.data.result.data);
          dataList.value = res.data.data.result.data;
          activeKey.value = res.data.data.result.data[0].ip
          console.log(activeKey.value, 'activeKey--=-=-==-=-=');
          // activeKey.value = 'info';
          activeType.value = res.data.data.result.data[0].mtype
          loading.value = false;
          select1.value = res.data.data.result.data[0].ip
          appStore.setIp(res.data.data.result.data[0].mtype, select1.value)
          getchn(res.data.data.result.data[0].ip, res.data.data.result.data[0].mtype)
          if (appStore.obj.ip) {
            flag.value = true
          } else {
            flag.value = false
          }
          // getchn(res.data.data.result.data[0].ip);
        })
        .catch(() => {
          //message.error("连接超时，请稍后再试！");
          loading.value = false;
        });
    }
    let spinflag = ref(true)
    function get_sav(ip?: any, mtype: any) {
      flag2.value = false
      if (activeType.value == 'MT710A') {
        get_outset({ ip: ip })
          .then((res) => {
            if (res.data.data.result.data != null) {
              flag2.value = true
              //chns.value = res.data.code == 200;
              outarr.value = res.data.data.result.data
              //type1chn.value = res.data.data.result.data[0].chn

              outsetParams.chn = res.data.data.result.data[tdindex.value].chn
              outsetParams.sip = res.data.data.result.data[tdindex.value].sip
              outsetParams.sport = res.data.data.result.data[tdindex.value].sport
              outsetParams.out_type = res.data.data.result.data[tdindex.value].out_type
              outsetParams.bbf = res.data.data.result.data[tdindex.value].bbf
              outsetParams.out_dest_ip = res.data.data.result.data[tdindex.value].out_dest_ip
              outsetParams.dport = res.data.data.result.data[tdindex.value].dport

              loading.value = false;
              if (flag1.value && flag2.value && flag3.value) {
                spinflag.value = false
              } else {
                spinflag.value = true
              }
            } else {
              outarr.value = undefined
              outsetParams.chn = ''
              outsetParams.sip = ''
              outsetParams.sport = ''
              outsetParams.out_type = ''
              outsetParams.bbf = ''
              outsetParams.out_dest_ip = ''
              outsetParams.dport = ''
            }

            // if (chnsetParams.chn_type == '1') {
            //     flags.value = false
            //   } else {
            //     flags.value = true
            //   }
          })
          .catch(() => {
            //message.error("连接超时，请稍后再试！");
            loading.value = false;
          });
        flag3.value = false
        get_saveset({ ip: ip })
          .then((res) => {

            if (res.data.data.result.data.length != null) {
              flag3.value = true
              //chns.value = res.data.code == 200;
              savearr.value = res.data.data.result.data
              //type1chn.value = res.data.data.result.data[0].chn

              savesetParams.chn = res.data.data.result.data[tdindex.value].chn
              savesetParams.data_processing = res.data.data.result.data[tdindex.value].data_processing
              savesetParams.file_size = res.data.data.result.data[tdindex.value].file_size
              savesetParams.file_count = res.data.data.result.data[tdindex.value].file_count
              savesetParams.output_path = res.data.data.result.data[tdindex.value].output_path
              savesetParams.stream_ip = res.data.data.result.data[tdindex.value].stream_ip;
              savesetParams.stream_port = res.data.data.result.data[tdindex.value].stream_port
              savesetParams.sat_name = res.data.data.result.data[tdindex.value].sat_name
              savesetParams.polar = res.data.data.result.data[tdindex.value].polar
              savesetParams.direct = res.data.data.result.data[tdindex.value].direct
              savesetParams.hdlc_type = res.data.data.result.data[tdindex.value].hdlc_type
              savesetParams.delbin = res.data.data.result.data[tdindex.value].delbin
              savesetParams.file_time = res.data.data.result.data[tdindex.value].file_time

              loading.value = false;
              if (flag1.value && flag2.value && flag3.value) {
                spinflag.value = false
              } else {
                spinflag.value = true
              }
            } else {
              savearr.value = undefined
              savesetParams.chn = ''
              savesetParams.data_processing = ''
              savesetParams.file_size = ''
              savesetParams.file_count = ''
              savesetParams.output_path = ''
              savesetParams.stream_ip = ''
              savesetParams.stream_port = ''
              savesetParams.sat_name = ''
              savesetParams.polar = ''
              savesetParams.direct = ''
              savesetParams.hdlc_type = ''
              savesetParams.delbin = ''
              savesetParams.file_time = ''
            }

            if (chnsetParams.chn_type == '1') {
              flags.value = false
            } else {
              flags.value = true
            }
          })
          .catch(() => {
            //message.error("连接超时，请稍后再试！");
            loading.value = false;
          });

      }
    }
    let flag1 = ref(false)
    let flag2 = ref(false)
    let flag3 = ref(false)
    let flaga = ref(true)
    function getchn(ip?: any, mtype: any) {
      console.log(ip, 'ip', mtype, 'mtype--')
      flag1.value = false
      loading.value = true;
      // resetcParams()
      chnsetParams.ip = ip;
      outsetParams.ip = ip;
      savesetParams.ip = ip;
      saveParams2.ip = ip;
      if (activeType.value == 'MT710A') {
        get_chnset1({ mtype: mtype })
          .then((res) => {
            if (res.data.data.result.data) {
              flag1.value = true
              chnarr1.value = res.data.data.result.data
              checked1.value = chnarr1.value[tdindex.value].status != 0 ? 3 : 0
              type1chn.value = chnarr1.value[tdindex.value].chn
              // chnOptions.value.forEach((item, index) => {
              //   item.value = chnarr1.value[index].chn
              // })
              chnOptions.value = chnarr1.value.map((x, i) => ({ ...x, value: x.chn, label: `通道${i + 1}` }))

              chnsetParams.chn = chnarr1.value[tdindex.value].chn
              chnsetParams.rfin = chnarr1.value[tdindex.value].rfin
              chnsetParams.f = chnarr1.value[tdindex.value].f
              chnsetParams.rdc = chnarr1.value[tdindex.value].rdc
              chnsetParams.si = chnarr1.value[tdindex.value].si
              chnsetParams.rt = chnarr1.value[tdindex.value].rt
              if (flag1.value && flag2.value && flag3.value) {
                spinflag.value = false
              } else {
                spinflag.value = true
              }
              if (flaga.value) {
                chnsetParams.chn_type = chnarr1.value[tdindex.value].chn_type
                if (chnsetParams.chn_type == 1) {
                  flags.value = false
                } else {
                  flags.value = true
                }
                flaga.value = false
              } else {
                if (chnsetParams.chn_type == '1') {
                  flags.value = false
                } else {
                  flags.value = true
                }
              }

            }

            loading.value = false;
          })
          .catch(() => {
            //message.error("连接超时，请稍后再试！");
            loading.value = false;
          });
        get_sav(ip, mtype)
      } else {
        get_chnset2({ ip: ip })
          .then((res) => {
            chns.value = res.data.code == 200;
            chnarr2.value = res.data.data.result.data
            saveParams2.chn = res.data.data.result.data[tdindex.value].chn
            saveParams2.listen_ip = res.data.data.result.data[tdindex.value].listen_ip
            saveParams2.listen_port = res.data.data.result.data[tdindex.value].listen_port
            saveParams2.data_type = res.data.data.result.data[tdindex.value].data_type
            saveParams2.data_processing = res.data.data.result.data[tdindex.value].data_processing
            saveParams2.file_size = res.data.data.result.data[tdindex.value].file_size
            saveParams2.file_count = res.data.data.result.data[tdindex.value].file_count
            saveParams2.output_path = res.data.data.result.data[tdindex.value].output_path
            saveParams2.stream_ip = res.data.data.result.data[tdindex.value].stream_ip
            saveParams2.stream_port = res.data.data.result.data[tdindex.value].stream_port
            saveParams2.fc = res.data.data.result.data[tdindex.value].fc
            saveParams2.rs = res.data.data.result.data[tdindex.value].rs
            saveParams2.sat_name = res.data.data.result.data[tdindex.value].sat_name
            saveParams2.polar = res.data.data.result.data[tdindex.value].polar
            saveParams2.direct = res.data.data.result.data[tdindex.value].direct
            saveParams2.hdlc_type = res.data.data.result.data[tdindex.value].hdlc_type
            saveParams2.delbin = res.data.data.result.data[tdindex.value].delbin
            saveParams2.ena = res.data.data.result.data[tdindex.value].ena
            checked2.value = res.data.data.result.data[tdindex.value].status != 0 ? 3 : 0
            loading.value = false;
          })
          .catch(() => {
            //message.error("连接超时，请稍后再试！");
            loading.value = false;
          });
      }
    }
    function changeModem(activeKey) {
      const arr1 = appStore.panes.filter((item) => item.ip == activeKey);

      if (activeKey != 'add') {
        activeType.value = arr1[0].mtype

        chnsetParams.ip = activeKey;
        chnsetParams.chn = 1;

        outsetParams.ip = activeKey;
        outsetParams.chn = 1;

        savesetParams.ip = activeKey;
        savesetParams.chn = 1;

        saveParams2.chn = 1;
        // getchn(activeKey);
      }
    }
    const tdindex = ref(0)
    function changChn(val: any) {
      let i = val - 1;
      tdindex.value = i
      type1chn.value = val;
      if (activeType.value == 'MT710A') {
        if (chnarr1.value == null || chnarr1.value[i] == null || chnarr1.value[i].length === 0) {
          resetChnsetParams()
        } else {
          chnsetParams.rfin = chnarr1.value[i].rfin;
          chnsetParams.f = chnarr1.value[i].f;
          chnsetParams.rdc = chnarr1.value[i].rdc;
          chnsetParams.si = chnarr1.value[i].si;
          chnsetParams.rt = chnarr1.value[i].rt;
          chnsetParams.chn_type = chnarr1.value[i].chn_type;
          checked1.value = chnarr1.value[i].status != 0 ? 3 : 0;

          checked2.value = chnarr1.value[i].ena;
          if (chnsetParams.chn_type == '1') {
            flags.value = false
          } else {
            flags.value = true
          }
        }
        if (outarr.value == null || outarr.value[i] == null || outarr.value[i].length === 0) {
          resetOutsetParams()
        } else {
          outsetParams.sip = outarr.value[i].sip
          outsetParams.sport = outarr.value[i].sport
          outsetParams.out_type = outarr.value[i].out_type
          outsetParams.bbf = outarr.value[i].bbf
          outsetParams.out_dest_ip = outarr.value[i].out_dest_ip
          outsetParams.dport = outarr.value[i].dport
        }
        if (savearr.value == null || savearr.value[i] == null || savearr.value[i].length === 0) {
          resetSavesetParams()
        } else {
          savesetParams.data_processing = savearr.value[i].data_processing
          savesetParams.file_size = savearr.value[i].file_size
          savesetParams.file_count = savearr.value[i].file_count
          savesetParams.output_path = savearr.value[i].output_path
          savesetParams.stream_ip = savearr.value[i].stream_ip
          savesetParams.stream_port = savearr.value[i].stream_port
          savesetParams.sat_name = savearr.value[i].sat_name
          savesetParams.polar = savearr.value[i].polar
          savesetParams.direct = savearr.value[i].direct
          savesetParams.hdlc_type = savearr.value[i].hdlc_type
          savesetParams.delbin = savearr.value[i].delbin
          savesetParams.file_time = savearr.value[i].file_time
        }
      } else {
        if (chnarr2.value[i] == null || chnarr2.value[i].length === 0) {
          resetParams2()
        } else {
          saveParams2.chn = val;
          saveParams3.chn = val
          saveParams4.chn = val
          checked1.value = chnarr2.value[i].status != 0 ? 3 : 0
          saveParams2.listen_ip = chnarr2.value[i].listen_ip
          saveParams2.listen_port = chnarr2.value[i].listen_port
          saveParams2.data_type = chnarr2.value[i].data_type
          saveParams2.data_processing = chnarr2.value[i].data_processing
          saveParams2.file_size = chnarr2.value[i].file_size
          saveParams2.file_count = chnarr2.value[i].file_count
          saveParams2.output_path = chnarr2.value[i].output_path
          saveParams2.stream_ip = chnarr2.value[i].stream_ip
          saveParams2.stream_port = chnarr2.value[i].stream_port
          saveParams2.fc = chnarr2.value[i].fc
          saveParams2.rs = chnarr2.value[i].rs
          saveParams2.sat_name = chnarr2.value[i].sat_name
          saveParams2.polar = chnarr2.value[i].polar
          saveParams2.direct = chnarr2.value[i].direct
          saveParams2.hdlc_type = chnarr2.value[i].hdlc_type
          saveParams2.delbin = chnarr2.value[i].delbin
        }
      }
    }
    function resetcParams() {
      checked1.value = 0;
      checked2.value = 0;
      chnsetParams.rfin = undefined;
      chnsetParams.f = undefined;
      chnsetParams.rdc = undefined;
      chnsetParams.si = undefined;
      chnsetParams.rt = undefined;

      outsetParams.sip = undefined,
        outsetParams.sport = undefined,
        outsetParams.out_type = undefined,
        outsetParams.bbf = undefined,
        outsetParams.out_dest_ip = undefined,
        outsetParams.dport = undefined,

        savesetParams.chn = undefined
      savesetParams.data_processing = undefined
      savesetParams.file_size = undefined
      savesetParams.file_count = undefined
      savesetParams.output_path = undefined
      savesetParams.stream_ip = undefined
      savesetParams.stream_port = undefined
      savesetParams.sat_name = undefined
      savesetParams.polar = undefined
      savesetParams.direct = undefined
      savesetParams.hdlc_type = undefined
      savesetParams.delbin = undefined
      savesetParams.file_time = undefined

      saveParams2.listen_ip = undefined
      saveParams2.listen_port = undefined
      saveParams2.data_type = undefined;
      saveParams2.data_processing = undefined
      saveParams2.file_size = undefined
      saveParams2.file_count = undefined
      saveParams2.output_path = undefined
      saveParams2.stream_ip = undefined
      saveParams2.stream_port = undefined
      saveParams2.fc = undefined
      saveParams2.rs = undefined
      saveParams2.sat_name = undefined
      saveParams2.polar = undefined
      saveParams2.direct = undefined
      saveParams2.hdlc_type = undefined
      saveParams2.delbin = undefined

    }
    function resetChnsetParams() {
      checked2.value = 0;

      chnsetParams.rfin = undefined
      chnsetParams.f = undefined
      chnsetParams.rdc = undefined
      chnsetParams.si = undefined
      chnsetParams.rt = undefined
    }
    function resetOutsetParams() {
      outsetParams.sip = undefined
      outsetParams.sport = undefined
      outsetParams.out_type = undefined
      outsetParams.bbf = undefined
      outsetParams.out_dest_ip = undefined
      outsetParams.dport = undefined
    }
    function resetSavesetParams() {
      savesetParams.chn = undefined
      savesetParams.data_processing = undefined
      savesetParams.file_size = undefined
      savesetParams.file_count = undefined
      savesetParams.output_path = undefined
      savesetParams.stream_ip = undefined
      savesetParams.stream_port = undefined
      savesetParams.sat_name = undefined
      savesetParams.polar = undefined
      savesetParams.direct = undefined
      savesetParams.hdlc_type = undefined
      savesetParams.delbin = undefined
      savesetParams.file_time = undefined
    }
    function resetParams2() {
      checked1.value = 0;

      saveParams2.listen_ip = undefined;
      saveParams2.listen_port = undefined;
      saveParams2.data_type = undefined;
      saveParams2.data_processing = undefined;
      saveParams2.file_size = undefined;
      saveParams2.file_count = undefined;
      saveParams2.output_path = undefined;
      saveParams2.stream_ip = undefined;
      saveParams2.stream_port = undefined;
      saveParams2.fc = undefined;
      saveParams2.rs = undefined;
      saveParams2.sat_name = undefined;
      saveParams2.polar = undefined;
      saveParams2.direct = undefined;
      saveParams2.hdlc_type = undefined;
      saveParams2.delbin = undefined;

    }
    let swithcLoading = ref(false)
    function changeSwitch(checked: any) {
      swithcLoading.value = true
      //saveParams.ena = checked;
      saveParams3.chn = type1chn.value
      saveParams3.status = checked;
      saveParams3.ip = activeKey.value
      if (checked != 0) {
        saveParams3.status = 1
      } else {
        saveParams3.status = 0
      }
      set_status(saveParams3)
        .then((res) => {
          if (res.data.data.result.data.code) {
            if (res.data.data.result.data.code == 200) {
              message.success('采集开关切换成功！');
              getchn(activeKey.value, activeType.value)
            } else if (res.data.data.result.data.code == 500) {
              checked1.value = checked == 1 ? 0 : 1
              message.error(res.data.data.result.data.message);
            } else {
              checked1.value = checked == 1 ? 0 : 1
              message.error('采集开关切换失败！');
            }
            loading.value = false;
            swithcLoading.value = false
          }

          //getList();
        })
        .catch((error) => {
          checked1.value = checked == 1 ? 0 : 1
          message.error('请求失败!',);
          getList();
          loading.value = false;
        });
    }
    function changeSwitch2() {
      chnsetParams.ena = checked2.value;
    }
    async function save_add() {
      const reg = /(25[0-5]|2[0-4]\d|[01]?\d\d?)(\.(25[0-5]|2[0-4]\d|[01]?\d\d?)){3}/;
      if (appStore.panes.length > 12) {
        message.error('可增加设备已达到上限！');
      } else if (!addParams.name || !addParams.ip || !addParams.mtype) {
        message.error('请完整填写！');
      } else if (!reg.test(addParams.ip)) {
        message.error('请输入正确的ip地址');
      } else {
        add_modem(addParams)
          .then(async (res) => {
            loading.value = false;
            message.success('添加成功！');
            get_modem({}).then((resa) => {
              appStore.setPanes(resa.data.data.result.data);
            });
          })
          .catch((error) => {
            message.error('请求失败', error.response.data.detail[0].msg);
            getList();
            loading.value = false;
          });
      }
    }
    function do_chnset() {
      spinflag.value = true
      if (checked1.value != 0) {
        message.error('提交保存前需要先停用该通道！');
        spinflag.value = false
      } else {
        let save_us = true
        console.log(chnsetParams.rt, 'rt')
        console.log(typeof chnsetParams.rt)
        if (!chnsetParams.f) {
          spinflag.value = false
          message.error('请完整填写解调配置！');
          save_us = false
        } else {
          chnsetParams.rt = parseInt(chnsetParams.rt)
          chnsetParams.f = parseInt(chnsetParams.f)
          let ck_rt = savesetParams.rt
          let ck_f = savesetParams.f
          if (!Number.isInteger(chnsetParams.rt)) {
            spinflag.value = false
            message.error('符号速率请输入整数！');
            save_us = false
          }
          // else if (!Number.isInteger(chnsetParams.rt)) {
          //   message.error('符号速率请输入整数！');
          //   save_us = false
          // }
          else if (chnsetParams.f < 950000000 || chnsetParams.f > 2150000000) {
            spinflag.value = false
            message.error('请输入合法频率范围！');
            save_us = false
          }
        }

        if (save_us == true) {
          chnsetParams.chn = type1chn.value
          set_chnset1(chnsetParams)
            .then((res) => {
              console.log(res.data);
              loading.value = false;
              message.success('提交成功！');
              spinflag.value = false
              getchn(activeKey.value, activeType.value)
              //getList();
            })
            .catch((error) => {
              message.error('请求失败', error.response.data.detail[0].msg);
              spinflag.value = false
              getList();
              loading.value = false;
            });
        }
      }
    }
    function do_outset() {
      spinflag.value = true
      if (checked1.value != 0) {
        spinflag.value = false
        message.error('提交保存前需要先停用采集！');
      } else {
        let save_us = true
        const ipRegex = /(25[0-5]|2[0-4]\d|[01]?\d\d?)(\.(25[0-5]|2[0-4]\d|[01]?\d\d?)){3}/;
        if (!outsetParams.sip || !outsetParams.out_dest_ip || !outsetParams.sport || !outsetParams.dport) {
          console.log(outsetParams)
          message.error('请完整填写解调配置！');
          spinflag.value = false
          save_us = false
        } else {
          outsetParams.sport = parseInt(outsetParams.sport)
          outsetParams.dport = parseInt(outsetParams.dport)
          if (outsetParams.sip == outsetParams.ip) {
            message.error('输出源ip不能和解调器ip相同！');
            spinflag.value = false
            save_us = false
          }
          else if (!ipRegex.test(outsetParams.sip) && outsetParams.sip) {
            spinflag.value = false
            message.error('请输入合法输出源ip！');
            save_us = false
          }
          else if (!ipRegex.test(outsetParams.out_dest_ip) && outsetParams.out_dest_ip) {
            message.error('请输入合法输出目的ip！');
            spinflag.value = false
            save_us = false
          }
          else if (outsetParams.sport < 1 || outsetParams.sport > 65535) {
            message.error('请输入合法输出源端口范围！');
            spinflag.value = false
            save_us = false
          }
          else if (outsetParams.dport < 1 || outsetParams.dport > 65535) {
            message.error('请输入合法输出目的端口范围！');
            spinflag.value = false
            save_us = false
          }
        }

        if (save_us == true) {
          outsetParams.chn = type1chn.value
          set_outset(outsetParams)
            .then((res) => {
              console.log(res.data);
              loading.value = false;
              message.success('提交成功！');
              spinflag.value = false
              getchn(activeKey.value, activeType.value)
              //getList();
            })
            .catch(() => {
              //message.error("连接超时，请稍后再试！");
              spinflag.value = false
              getList();
              loading.value = false;
            });
        }
      }
    }
    function do_saveset() {
      // spinflag.value = true
      if (checked1.value != 0) {
        spinflag.value = false
        message.error('提交保存前需要先停用采集！');
      } else {
        let save_us = true
        const ipRegex = /(25[0-5]|2[0-4]\d|[01]?\d\d?)(\.(25[0-5]|2[0-4]\d|[01]?\d\d?)){3}/;
        if (chnsetParams.chn_type == 0) {
          if (!savesetParams.sat_name || !savesetParams.file_count || !savesetParams.file_size) {
            spinflag.value = false
            console.log(savesetParams)
            message.error('请完整填写解调配置！');
            console.log(savesetParams)
            save_us = false
          } else {
            savesetParams.sat_name = parseInt(savesetParams.sat_name)
            savesetParams.file_count = parseInt(savesetParams.file_count)
            savesetParams.file_size = parseInt(savesetParams.file_size)

            console.log(savesetParams, "22")
            let ck_sat_name = savesetParams.sat_name
            let ck_file_count = savesetParams.file_count
            let ck_file_size = savesetParams.file_size
            if (!Number.isInteger(ck_sat_name)) {
              spinflag.value = false
              message.error('卫星名称请输入整数！');
              savesetParams.sat_name = ""
              save_us = false
            } else if (savesetParams.sat_name.length > 4 || savesetParams.sat_name.length == 0) {
              spinflag.value = false
              message.error('卫星名称的长度在1-4位之间！');
              save_us = false
            } else if (!Number.isInteger(ck_file_count)) {
              spinflag.value = false
              message.error('输出文件个数请输入整数！！');
              save_us = false
            } else if (!Number.isInteger(ck_file_size)) {
              spinflag.value = false
              message.error('输出文件大小请输入整数！！');
              save_us = false
            }
            else if (savesetParams.stream_port) {
              savesetParams.stream_port = parseInt(savesetParams.stream_port)
              if (!Number.isInteger(savesetParams.stream_port)) {
                console.log(22)
                spinflag.value = false
                message.error('流转发端口请输入整数！！');
                savesetParams.stream_port = ""
                save_us = false
              }
            }
            else if (savesetParams.file_count < 0) {
              if (savesetParams.file_count === -1) {
              } else {
                spinflag.value = false
                message.error('输出文件个数请输入合法整数！');
                save_us = false
              }

            }
            else if (savesetParams.stream_ip) {
              console.log("222")
              if (!ipRegex.test(savesetParams.stream_ip)) {
                spinflag.value = false
                message.error('流转发IP请输入合法ip！！');
                save_us = false
              }
            }
            else if (savesetParams.stream_port && savesetParams.stream_port < 1 || savesetParams.stream_port > 65535) {
              message.error('流转发端口请输入合法范围！');
              spinflag.value = false
              savesetParams.stream_port = ""
              save_us = false
            }
          }

          //输出文件个数可以是-1，不能是0及其他负整数。

          if (save_us == true) {
            if (typeof savesetParams.sat_name != 'string') {
              // 如果num不是字符串，则将其转换为字符串  
              savesetParams.sat_name = savesetParams.sat_name.toString();
              if (savesetParams.sat_name.length > 4 || savesetParams.sat_name.length == 0) {
                spinflag.value = false
                message.error('卫星名称的长度在1-4位之间！');
                save_us = false
              } else if (isNaN(parseInt(savesetParams.sat_name))) {
                spinflag.value = false
                message.error('卫星名称请输入整数！');
              } else {
                set_saveset(savesetParams)
                  .then((res) => {
                    console.log(res.data);
                    spinflag.value = false
                    loading.value = false;
                    message.success('提交成功！');
                    getList();
                  })
                  .catch((error) => {
                    message.error('请求失败', error.response.data.detail[0].msg);
                    spinflag.value = false
                    getList();
                    loading.value = false;
                  });
              }
            }
          }
        } else {
          if (!savesetParams.file_size || !savesetParams.file_time) {
            console.log(savesetParams)
            message.error('请完整填写解调配置！');
            spinflag.value = false
            console.log(savesetParams)
            save_us = false
          } else {
            savesetParams.sat_name = parseInt(savesetParams.sat_name)
            savesetParams.file_count = parseInt(savesetParams.file_count)
            savesetParams.file_size = parseInt(savesetParams.file_size)

            let ck_sat_name = savesetParams.sat_name
            let ck_file_count = savesetParams.file_count
            let ck_file_size = savesetParams.file_size
            if (!Number.isInteger(Number(savesetParams.file_time))) {
              spinflag.value = false
              message.error('采样时间请输入整数！！');
              save_us = false
            }
            if (!Number.isInteger(ck_file_size)) {
              spinflag.value = false
              message.error('输出文件大小请输入整数！！');
              save_us = false
            }
            else if (savesetParams.file_count < 0) {
              if (savesetParams.file_count === -1) {
              } else {
                message.error('输出文件个数请输入合法整数！');
                spinflag.value = false
                save_us = false
              }

            }
          }

          //输出文件个数可以是-1，不能是0及其他负整数。

          if (save_us == true) {
            console.log(chnsetParams.chn_type, 'chnsetParams.chn_type=-=-=--=--=-=')

            // savesetParams.sat_name = savesetParams.sat_name.toString();
            savesetParams.chn = type1chn.value
            if (chnsetParams.chn_type == 1) {
              set_saveset({ ip: savesetParams.ip, chn: savesetParams.chn, file_size: savesetParams.file_size, file_time: savesetParams.file_time, delbin: savesetParams.delbin })
                .then((res) => {
                  console.log(res.data);
                  spinflag.value = false
                  loading.value = false;
                  message.success('提交成功!');
                  getList();
                })
                .catch((error) => {
                  message.error('请求失败', error.response.data.detail[0].msg);
                  spinflag.value = false
                  getList();
                  loading.value = false;
                });
            } else {
              if (typeof savesetParams.sat_name != 'string') {
                // 如果num不是字符串，则将其转换为字符串  
                savesetParams.sat_name = savesetParams.sat_name.toString();
                if (savesetParams.sat_name.length > 4 || savesetParams.sat_name.length == 0) {
                  spinflag.value = false
                  message.error('卫星名称的长度在1-4位之间！');
                  save_us = false
                } else if (isNaN(parseInt(savesetParams.sat_name))) {
                  spinflag.value = false
                  message.error('卫星名称请输入整数！');
                } else {
                  set_saveset(savesetParams)
                    .then((res) => {
                      console.log(res.data);
                      spinflag.value = false
                      loading.value = false;
                      message.success('提交成功！');
                      getList();
                    })
                    .catch((error) => {
                      message.error('请求失败', error.response.data.detail[0].msg);
                      spinflag.value = false
                      getList();
                      loading.value = false;
                    });
                }
              }

            }

          }
        }

      }
    }
    function do_Save2() {
      if (checked1.value != 0) {
        message.error('提交保存前需要先停用采集！');
      }
      else {
        set_chnset2(saveParams2)
          .then((res) => {
            console.log(res.data);
            getchn(activeKey.value, activeType.value)
            loading.value = false;
            message.success('提交成功！');
            //getList();
          })
          .catch(() => {
            //message.error("连接超时，请稍后再试！");
            getList();
            loading.value = false;
          });
      }
    }
    function do_del(ip: string) {
      // message.error('删除功能暂未添加！');
      // return;
      Modal.confirm({
        title: () => '确定删除该服务器？',
        icon: () => createVNode(ExclamationCircleOutlined),
        content: () => '',
        onOk() {
          loading.value = true;
          del_modem({ ip: ip }).then((res) => {
            if (res.data.code == 200) {
              message.success('删除成功！');
              getList();
              loading.value = false;
            } else {
              message.error('删除失败！');
            }
          });
        },
        onCancel() {
          console.log('Cancel');
        },
      });
    }
    function filters(text: any) {
      let newtext = truncateString(text);
      return newtext;
    }
    function truncateString(text: any) {
      let totalLength = 0;
      let truncated = '';
      if (!text) return '';
      for (const i of text) {
        const char = i;
        if (/[\u4e00-\u9fa5]/.test(char)) {
          // 汉字
          totalLength += 2;
        } else {
          // 英文字符
          totalLength += 1;
        }
        if (totalLength <= 20) {
          truncated += char;
        } else {
          truncated += '...';
          break;
        }
      }
      //console.log(truncated);
      return truncated;
    }
    return {
      dataList,
      columns,
      paginationOption,
      labelCol: { span: 6 },
      wrapperCol: { span: 18 },
      queryParams,
      checked1,
      checked2,
      panes,
      img3,
      addParams,
      activeKey,
      t,
      tabPosition,
      save_add,
      typeOptions,
      chnOptions,
      chn2Options,
      formatOptions,
      rfinOptions,
      bbOptions,
      workingModeOptions,
      spectralInversionOptions,
      rolloffFactorOptions,
      output_formatOptions,
      delbinOptions,
      chn_BBFOptions,
      chnsetParams,
      outsetParams,
      savesetParams,
      saveParams2,
      changeModem,
      changChn,
      changeSwitch,
      changeSwitch2,
      do_saveset,
      do_chnset,
      do_outset,
      do_Save2,
      chns,
      do_del,
      filters,
      appStore,
      activeType,
      polarOptions,
      directOptions,
      hdlcTypeOptions,
      dataTypeOptions,
      dataProcessingOptions,
      type1chn,
      changeck,
      flag,
      guanbi,
      Pattern,
      swithcLoading,
      Pattern_click,
      select1,
      flags,
      tdindex,
      flaga,
      patterns,
      spinflag,
      flag1,
      flag2,
      flag3,
      outPath,
      get_outPath,
      out_save,
      checkbox1,
      checkbox2,
      checkbox3
    };
  },
});
</script>

<style lang="less" scoped>
.spane1 {
  color: #0960bd;
  cursor: pointer;
}

.list1 {
  padding: 20px 0;
}

.content1 {
  padding: 15px 0;
  text-indent: 24px;
}

.hh1 {
  line-height: 34px;
  text-align: center;
  font-weight: bold;
}

.dd1 {
  line-height: 34px;
}

.dd2 {
  line-height: 34px;
  text-indent: 24px;
}

.dd3 {
  line-height: 34px;
  text-indent: 24px;
  float: right;
  margin: 20px 0;
}

.tb1 {
  background: #fff;
  padding-top: 10px;
}

.menu_list {
  display: flex;
  margin-top: 30px;
  height: 120px;
}

.menu_list_item {
  margin: 0 20px;
  width: 120px;
  height: 60px;
  padding: 5px 0;
  border-radius: 10px;
  text-align: center;
  border: 5px solid #87e8de;
  color: #08979c;
  background: #e6fffb;
}

.icon4 {
  position: relative;
  top: 2px;
}

.icon5 {
  position: relative;
  top: 0px;
  left: 10px;
  margin-right: 20px;
}

.box2 {
  margin: 30px 0;
  padding-bottom: 150px;
}

.add1 {
  color: #0960bd;
  display: block;
  width: 100%;
  height: 100%;
}

.ant-tabs-tab-active .add1 {
  color: #fff;
}

.titlea1 {
  width: 100%;
  line-height: 36px;
  font-size: 16px;
  text-align: center;
  color: #fff;
  font-weight: bold;
  margin: 10px 0 20px 0;
}

.ant-tabs {
  margin-top: 20px;
}
</style>
<style>
.ant-tabs-bar {
  margin: 0;
}

.ant-tabs-nav .ant-tabs-tab {
  height: 160px;
  background: #e6fffb;
}

.ant-tabs-nav .ant-tabs-tab .anticon {
  margin-left: 8px;
}

.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab-active {
  border: 1px solid #0960bd;
  border-bottom: 0;
}

/*.ant-tabs-tab-active .app-iconify{
  color: #fff !important;
}*/
.ant-divider-horizontal {
  border-color: #fff;
  margin-bottom: 35px;
}

.ant-input {
  color: #fff;
}

.ant-select-selection-item,
.ant-divider-dashed {
  color: #fff;
}

.ant-form-item-control-input-content {
  color: #ccc;
}

.notice1 {
  width: 100%;
  padding-top: 150px;
  text-align: center;
  color: #fff;
  font-size: 16px;
  padding-bottom: 100px;
}

.spanf1 {
  color: #05e618;
}

.ant-tabs-tab {
  position: relative;
}

.del {
  width: 20px;
  height: 20px;
  position: absolute;
  z-index: 33;
  right: 5px;
  top: -8px;
}
</style>
<style lang='less'>
.ant-tabs .ant-tabs-left-bar .ant-tabs-nav-wrap {
  height: 600px;
  overflow-y: scroll;
}

.ant-select-clear {
  background: #3B3D3E;
}

.anticon {
  color: #fff;
}

.ant-divider-horizontal {
  margin-bottom: 0;
}

.p-5 {
  padding-top: 55px !important;
}

.example {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  width: 97%;
  height: 120%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  z-index: 2;
}
</style>